package com.zhaozhaonews.wemedia.controller;


import com.zhaozhaonews.model.common.dto.ResponseResult;
import com.zhaozhaonews.model.wemedia.dto.WmNewsDownOrUpDto;
import com.zhaozhaonews.model.wemedia.dto.WmNewsDto;
import com.zhaozhaonews.model.wemedia.dto.WmNewsPageReqDto;
import com.zhaozhaonews.model.wemedia.entity.WmNews;
import com.zhaozhaonews.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 自媒体图文内容信息表 前端控制器
 * </p>
 *
 * @author WanJL
 * @since 2025-02-17
 */
@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {
    @Resource
    private WmNewsService wmNewsService;

    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmNewsPageReqDto wmNewsPageReqDto) {
        return wmNewsService.list(wmNewsPageReqDto);
    }

    @PostMapping("/submit")
    public ResponseResult submitNews(@RequestBody WmNewsDto dto){
        return wmNewsService.submitNews(dto);
    }
    @GetMapping("/one/{newsId}")
    public ResponseResult getOne(@PathVariable Integer newsId) {
        WmNews wmNews = wmNewsService.lambdaQuery().eq(WmNews::getId, newsId).one();
        return ResponseResult.okResult(wmNews);
    }

    @PostMapping("/down_or_up")
    public ResponseResult downOrUp(@RequestBody WmNewsDownOrUpDto dto){
        return wmNewsService.downOrUp(dto);
    }
}

